public class PassingArrMaxMin {
    public static void main(String[] args) {

        int[] arr = {12,23,11,25,76};
        int[] getMaxMin = getMaxMin(arr);
        System.out.println("最大的数为" + getMaxMin[0]);
        System.out.println("最小的数为" + getMaxMin[1]);
    }

    public static int[] getMaxMin(int[] arr){
        int max = arr[0],min = arr[0];
        for(int i = 1;i < arr.length;i++){
            if(max < arr[i]){
                max = arr[i];
            }else if(min > arr[i]){
                min = arr[i];
            }
        }
        return new int[]{max,min};
    }
    /*已在上方优化
    public static int getSmaller(int[] arr){
        int min = arr[0];
        for(int i = 1;i < arr.length;i++){
            if(min > arr[i]){
                min = arr[i];
            }
        }
        return min;
    }
    */
}


